<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "diy".
 *
 * @property integer $id
 * @property string $name
 * @property string $tips
 * @property integer $space_id
 * @property integer $app_return
 * @property integer $img_small_id
 * @property integer $img_thumb_id
 * @property integer $img_url_id
 * @property integer $top_time
 */
class Diy extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'diy';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['space_id', 'app_return', 'img_small_id', 'img_thumb_id', 'img_url_id', 'top_time'], 'integer'],
            [['name'], 'string', 'max' => 64],
            [['tips'], 'string', 'max' => 512]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => Yii::t('app','Diy Name'),
            'tips' => Yii::t('app','Diy Tips'),
            'space_id' => Yii::t('app','Diy Space ID'),
            'app_return' => Yii::t('app','Diy App Return'),
            'img_small_id' => Yii::t('app','Diy Img Small ID'),
            'img_thumb_id' => Yii::t('app','Diy Img Thumb ID'),
            'img_url_id' => Yii::t('app','Diy Img Url ID'),
            'top_time' => Yii::t('app','Diy Top Time'),
        ];
    }
    public function getSpaceName(){
    	return $this->hasOne(GrpSpace::className(),['id'=>'space_id']);//显示小图
    }
    public function getSmallImg() {
        return $this->hasOne(Image::className(), ['id' => 'img_small_id']);
    }
}
